
/**
 * 提示框
 * @param {*} param0 
 */
const toast = ({
  title = "数据加载中...",
  icon = "none",
  duration = 2000,
  mask = true
} = {}) => {
  wx.showToast({
    title,
    icon,
    duration,
    mask
  })
}

/**
 * 模态对话框
 * @param {*} options 
 */
const modal=(options={})=>{
  const defaultOpt={
    title: '提示',
    content: '你确定执行该操作吗？',
    confirmColor:'#f3514f'
  }
  const opt=Object.assign({},defaultOpt,options)
  return new Promise((resolve)=>{
    wx.showModal({
      ...opt,
      complete: (res) => {
        if(res.confirm){
          resolve(true)
        }
        if(res.cancel){
          resolve(false)
        }
      }
    })
  })
  
}

wx.toast = toast
wx.modal=modal

export {
  toast,modal
}